<template>
    <div class="ma-content-block lg:flex justify-between p-4">
      <!-- CRUD 组件 -->
      <ma-crud :options="options" :columns="columns" ref="crudRef" :isTotal='isTotal'>
        <template #operationCell="{ record }">
            <a-link @click='handlethrough(record)'><icon-desktop /> 通行记录</a-link>
        </template>
      </ma-crud>
      
    </div>
  </template>
  <script setup>
  import { ref, reactive,defineProps } from 'vue'
  import predictionBoxManage from '@/api/prediction/predictionBoxManage'
  import through from '../through/through.vue'
  import { Message } from '@arco-design/web-vue'
  import tool from '@/utils/tool'
  import * as common from '@/utils/common'
  const isTotal = ref(true)
  const crudRef = ref()
  const props = defineProps({
        plateNo: {
            default: null,
        },
  });
  const numberOperation = (newValue, id, numberName) => {
    predictionBoxManage.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  
  const switchStatus = (statusValue, id, statusName) => {
    predictionBoxManage.changeStatus({ id, statusName, statusValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  
  
  const options = reactive({
    id: 'flyos_prediction_through',
    rowSelection: {
      showCheckedAll: true
    },
    pk: 'id',
    operationColumn: false,
    operationWidth: 160,
    pageSize:50,
    pageSizeOption:[50,100,200],
    formOption: {
      viewType: 'modal',
      width: 600
    },
    api: predictionBoxManage.getPmsLogs,
    add: {
      show: false,
      api: predictionBoxManage.getPmsSave,
      
    },
    edit: {
      show: false,
      text: '修改',
      barrier:true,
      api: predictionBoxManage.getPmsSave,
    },
    delete: {
      show: false,
      barrier:true,
      api: predictionBoxManage.getPmsdelete,
    },
    recovery: {
      show: false,
      api: predictionBoxManage.recoverys,
      auth: ['prediction:boxManage:recovery']
    },
    import: {
      show: false,
      url: 'prediction/boxManage/import',
      templateUrl: 'prediction/boxManage/downloadTemplate',
      auth: ['prediction:boxManage:import']
    },
    export: {
      show: false,
      url: 'prediction/boxManage/export',
      auth: ['prediction:boxManage:export']
    },
    beforeRequest:(params)=>{
        params.plateNo = props.plateNo
    }
  })
  
  const columns = reactive([
    {
      title: "",
      dataIndex: "id",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      hide: true,
      commonRules: {
        required: true,
        message: "请输入"
      }
    },
    {
      title: "车牌号码",
      dataIndex: "plateNo",
      formType: "input",
      width:140,
    },
    {
      title: "过车行驶方向",
      dataIndex: "direction",
      formType: "select",
      width:140,
      dict: {
		data() {
			return [
			{ label: "入场过车", value: 0 },
			{ label: "出场过车", value: 1 },
			];
		},
		translation: true,
		tagColors: {
			0: "green",
			1: "red",
		},
	  },
    },
    {
      title: "出入口名称",
      dataIndex: "gateName",
      formType: "input",
      width:140,
    },
    {
      title: "通行方式",
      dataIndex: "passType",
      formType: "input",
      width:100,
    },
    {
			title: "过车图片",
			dataIndex: "picFilePath",
			formType: "upload",
			width:120,
			align: "center",
		},
    {
			title: "过车车牌",
			dataIndex: "plateFilePath",
			formType: "upload",
			width:120,
			align: "center",
		},
    {
      title: "通行时间",
      dataIndex: "passTime",
      formType: "date",
      showTime: true,
     
    },
    
    {
      title: "更新者",
      dataIndex: "updated_by",
      formType: "date",
      addDisplay: false,
      editDisplay: false,
      hide: true,
      showTime: true
    }
  ])
  </script>
  <script> export default { name: 'prediction:through' } </script>